package com.wjb.xietong.server.taskReply;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import com.wjb.xietong.server.IRequestParam;
import com.wjb.xietong.util.Base64;
import com.wjb.xietong.util.IDs;
import com.wjb.xietong.util.LogD;

public class TaskFileUploadParam implements IRequestParam{
	
	private long companyId = 0l;
	private long userId = 0l;
	private String filePath = null;

	@Override
	public Map<String, String> parseData2Map() {
		Map<String, String> map = new HashMap<String, String>();
		put(map, IDs.M, IDs.FILE_UPLOAD);
		put(map, IDs.COM_ID, getCompanyId());
		put(map, IDs.USER_ID, getUserId());
		put(map, IDs.BASE64FILE, getBase64File());
		return map;
	}
	
	private void put(Map<String, String> map, String key, long value) {
		put(map, key, String.valueOf(value));
	}

	private void put(Map<String, String> map, String key, String value) {
		if (null == key || null == value) {
			return;
		}
		map.put(key, value);
	}

	public long getCompanyId() {
		return companyId;
	}

	public void setCompanyId(long companyId) {
		this.companyId = companyId;
	}

	public long getUserId() {
		return userId;
	}

	public void setUserId(long userId) {
		this.userId = userId;
	}
	
	public String getBase64File(){
		try {
			return Base64.encodeFile(filePath);
		} catch (IOException e) {
			LogD.output("Exception:" + e.getMessage());
		}
		return null;
	}

	public String getFilePath() {
		return filePath;
	}

	public void setFilePath(String filePath) {
		this.filePath = filePath;
	}
}
